<template>
	<view class="content">
		<view class="course-wrap">
			<view class="titBox" v-for="(data,indexs) in list" :key="indexs">
				<view class="titBox_in">
					<view class="showTitle" @click="loadData(data.id,indexs)">{{data.text}}
						<span :class="['spans',data.showContent == 1 ? 'down':'']">&#xe65e;</span>
					</view>
					<view :class="['contentBox',data.showContent == 1? 'open':'']">
						<view @click="toLink(item.id)" class="item" v-for="(item, index) in studylist" :key="item.id">
							<view class="item-content">
								<view>
									<image :src="item.img" class="item-img"></image>
								</view>
								<view class="item-right">
									<view class="item-title">{{ item.title}}</view>
									<view v-html="ToText(item.content)" class="item-desc"></view>
									<view class="item-num">
										<image class="item-icon"  src="/static/course/icon-2man.png"></image>
										<text>{{item.readVolume}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>

				</view>


			</view>
		</view>
	</view>
	<!--  -->


</template>

<script>
	import baseService from '@/services/study/index.js';
	const service = new baseService();
	export default {
		name: "levelVideoContent",
		props: {
			list: {
				type: Array,
				default: function() {
					return [];
				}
			},
			type: {
				type: String
			},
			levelId: {
				type: String
			},
			liIndex: {
				type: Number
			}

		},
		data() {
			return {
				studylist: []
			}
		},
		methods: {
			ToText(HTML) {
				if (HTML != null || HTML != undefined || HTML != '') {
					return
				}
				var input = HTML;
				return input.replace(/<(style|script|iframe)[^>]*?>[\s\S]+?<\/\1\s*>/gi, '').replace(/<[^>]+?>/g, '').replace(
					/\s+/g, ' ').replace(/ /g, ' ').replace(/>/g, ' ');
			},
			loadData(id, index) {
				// if (( this.list[0].showContent == 1 ) ||
				//  (index != 0 && this.list[index].showContent == 0)) {
				service.studyVideoList(id, this.type, 1, 100, null).then(res => {
					this.studylist = res.result.list;
					this.$emit('toggleShow', index)
				})
				// }
				// if(this.list[0].showContent == 1 ){
				// this.list[index].showContent = (this.list[index].showContent == 1) ? 0 : 1

				// }


			},
			toLink(id) {
				uni.navigateTo({
					url: '/pages/tabbar/study/details/index?id=' + id + '&type=0'
				})
			}
		}
	}
</script>

<style lang="less">
	// 列表
	.container {
		overflow: hidden;
	}


	.contentBox {
		height: 0px;
		overflow: hidden;
	}

	.open {
		height: max-content;
	}
	.content {
		overflow-y: scroll;
		height: calc(100vh - 28px);
	}

	.course-wrap {
		background-color: #fff;
		height: 100%;

		.titBox {
			padding: 0 29upx;

			.titBox_in {
				border-bottom: 1upx solid #eee;

				.showTitle {
					padding: 30upx 0upx;
					font-size: 22rpx;

					.spans {
						transform: rotate(-90deg);
						display: inline-block;
						font-size: 11px;
						color: #555;
						margin-left: 20upx;
						font-family: texticons;
					}

					.down {
						transform: rotate(90deg);
						transition: .3s; //过渡时间
					}
				}
			}
		}


	}

	.item:first-child {
		.item-content {
			border-top: 0;
		}
	}



	.item {
		position: relative;

		&-content {
			display: flex;
			align-items: center;
			padding: 20upx 0;
			border-top: 1px #dddddd solid;
			background-color: #fff;
		}

		&-tag {
			position: absolute;
			right: 0;
			top: 0;
			background-color: #4a96f2;
			border-bottom-left-radius: 8upx;
			color: #FFFFFF;
			font-size: 18upx;
			padding: 0 5upx;
		}

		&-img {
			width: 243upx;
			height: 167upx;
			border-radius: 8upx;
		}

		&-right {
			margin-left: 20upx;
		}

		&-title {
			font-size: 28upx;
			color: #333;
			font-weight: bold;
			line-height: 36upx;
		}

		&-desc {
			font-size: 24upx;
			color: #666;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 3;
			height: 100upx;
			overflow: hidden;
			padding: 8upx 0 0 0;
		}

		&-num {
			font-size: 20upx;
			color: #999999;
		}

		&-icon {
			width: 21upx;
			height: 20upx;
			margin-right: 4upx;

		}
	}
</style>
